package com.heima.mapper;

import com.github.pagehelper.Page;
import com.heima.pojo.Node;
import com.heima.pojo.VmType;
import com.heima.pojo.dto.NodePageSearchQueryDTO;
import com.heima.pojo.vo.BusinessTypeVO;
import com.heima.pojo.vo.NodePageSearchQueryVO;
import com.heima.pojo.vo.NodeVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NodeMapper {
   @Select("select count(*) from tb_node where region_id = #{regionId}")
    Integer nobeCount(Long id);


    @Delete("delete from tb_node where region_id = #{regionId}")
    void deleteNodeId(Long regionId);

    Page<NodePageSearchQueryVO> pageSearch(NodePageSearchQueryDTO dto);


 @Select("select * from tb_node where region_id = #{id}")
    List<Node> getByRegionId(Long regionId);

    @Select("select * from tb_business")
    List<BusinessTypeVO> selectType();

    void add(Node node);

    @Select("select * from tb_vending_machine where node_id=#{nodeId}")
    List<NodeVO> selectNodeId(Long nodeId);

    @Select("select * from tb_vm_type where type_id = #{vmTypeId}" )
    VmType selectTypeId(Long vmTypeId);

    @Select("select * from tb_node where id = #{regionId}")
    Node selectByNodeId(Integer regionId);

    @Delete("delete from tb_node where id = #{nodeId} ")
    void deleteById(Long nodeId);

    void updateNode(Node node);
}
